<template>
<div class="shadow-info-cp box-shadow_2">
    <div class="top">
        <div 
            class="top"
            :style="'background-color:'+dataInfo.background_outside+';'">
            <div 
                class="contrainer"
                :style="dataInfo.shadow+'background-color:'+dataInfo.background+';'">
                <ColorPicker
                    v-model="dataInfo.background">
                </ColorPicker>
            </div>
            <div class="copy">
                <Copy
                    title="css"
                    :content="dataInfo.shadow">
                </Copy>
            </div>
            <div class="last-and-next">
                <LastNext
                    @onLast="onLast"
                    @onNext="onNext"
                    :lastState="lastData!==0"
                    :nextState="nextData!==0">
                </LastNext>
            </div>
            <ColorPicker
                v-model="dataInfo.background_outside">
            </ColorPicker>
        </div>
    </div>
    <div class="title">
        {{dataInfo.name}}
    </div>
    <div class="color-list">
        <ColorList
            :colorList="dataInfo.shadow + dataInfo.background +' '+ dataInfo.background_outside +' '">
        </ColorList>
    </div>
    <div class="bottom">
        <div class="left">
            <div class="item bt">
                <Like
                    type="shadow"
                    :dataInfo="itemData"
                    :number="itemData.like">
                </Like>
            </div>
            <div class="item bt">
                <LinkBt
                    :link="$route.path">
                </LinkBt>
            </div>
            <div class="item tag">
                <Tags
                    :tags="dataInfo.tags"
                    :type="2">
                </Tags>
            </div>
        </div>
        <div class="right">
            <Date
                :date="dataInfo.init_date">
            </Date>
        </div>
    </div>
</div>
</template>

<script>
import Like from '@/components/other/Like';
import LinkBt from '@/components/other/Link';
import Date from '@/components/other/Date';
import Tags from '@/components/other/Tags';
import Copy from '@/components/other/Copy';
import LastNext from '@/components/other/LastNext';
import ColorList from '@/components/other/ColorList';
import ColorPicker from '@/components/other/ColorPicker';
export default {
    components: {
        Like,
        Date,
        LinkBt,
        ColorList,
        Tags,
        Copy,
        LastNext,
        ColorPicker,
    },
    props:{
        dataInfo:{ //对象数据
            type:Object,
            default:()=>{
                return {};
            },
        },
        lastData:{ //上一个shadow ID
            type:Number,
            default:0,
        },
        nextData:{
            type:Number,
            default:0,
        },
    },
    methods:{
        onLast(){
            if(!this.lastData) return;
            this.$router.push({
                name:'Shadow',
                params:{
                    id:this.lastData,
                },
            }).catch(() => {return;});
        },
        onNext(){
            if(!this.nextData) return;
            this.$router.push({
                name:'Shadow',
                params:{
                    id:this.nextData,
                },
            }).catch(() => {return;});
        },
    },
}
</script>
<style lang="scss" scoped>
.shadow-info-cp{
    width: 100%;
    border: none;
    background-color: white;
    padding: 15px;
    box-sizing: border-box;
    border-radius: 5px;
    >.top{
        border-radius: 5px;
        >.top{
            width: 100%;
            position: relative;
            display: flex;
            padding: 30px 0;
            box-sizing: border-box;
            justify-content: center;
            align-items: center;
            border: 1px solid #e9f2f9;
            border-radius: 5px;
            /deep/.colorPicker{
                border-radius: 3px;
                position:absolute;
                top: 10px;
                right: 10px;
                opacity: 0;
            }
            >.contrainer{
                width: 300px;
                height: 300px;
                border-radius: 3px;
                position: relative;
                /deep/.colorPicker{
                    border-radius: 3px;
                    position:absolute;
                    top: 10px;
                    right: 10px;
                    opacity: 0;
                }
            }
            >.copy{
                width: fit-content;
                position: absolute;
                bottom: 5px;
                left: 5px;
                opacity: 0;
                transition: all 0.2s;
                /deep/.Copy{
                    border-radius: 3px;
                    font-weight: bold;
                }
            }
            &:hover{
                >.copy{
                    opacity: 1;
                }
                /deep/.colorPicker{
                    opacity: 1;
                }
            }
            >.last-and-next{
                position: absolute;
                top: 0;
                right: 0;
                height: 100%;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                padding: 10px;
                box-sizing: border-box;
                width: fit-content;
                opacity: 0;
                transition: all 0.2s;
                &:hover{
                    opacity: 1;
                }
            }
        }
    }
    >.title{
        font-size: 1.1rem;
        line-height: 1.1rem;
        font-weight: bold;
        margin-top: 15px;
        display:none;
    }
    >.color-list{
        background-color: #ffffff;
        /deep/.ColorList{
            >div{
                margin: 0 7.5px;
                margin-top: 15px;
            }
        }
    }
    >.bottom{
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-top: 15px;
        >.left{
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            align-items: center;
            >.item{
                margin-right: 15px;
            }
            >.bt{
                /deep/div{
                    padding: 10px 15px;
                }
            }
        }
        /deep/.right{
            >div{
                font-size: 1.2rem;
                line-height: 1.2rem;
                font-weight: bold;
            }
        }
    }
}
</style>

